﻿
Imports remotecall

Public Class rc4Detector
    Inherits rcDetector(Of rcserve4, fromBytes(), toBytes())

    Protected Overrides Function create_output() As toBytes()
        Dim rtn() As toBytes = Nothing
        ReDim rtn(0)
        Return rtn
    End Function

    Protected Overrides Function create_server(ByVal port As Int32, ByVal connectionCount As Int64) As rcserve4
        Return New rcserve4()
    End Function

    Protected Overrides Sub inject_output_ijob(ByVal i() As toBytes, ByVal job As ijob)
        i(0) = job
    End Sub

    Protected Overrides Function parse_input_ijob(ByVal i() As fromBytes, ByRef o As ijob) As Boolean
        Return i(0).cast(Of ijob)(o)
    End Function

    Protected Overrides Function parse_input_valid(ByVal i() As fromBytes) As Boolean
        Return Not i Is Nothing AndAlso i.Length() = 1
    End Function

    Protected Overrides Sub register(ByVal server As rcserve4,
                                     ByVal name As String,
                                     ByVal d As _do(Of fromBytes(), pointer(Of toBytes()), eventComb))
        assert(server.register(name, d))
    End Sub

    Protected Overrides Function start_server(ByVal server As rcserve4,
                                              ByVal port As Int32,
                                              ByVal connectionCount As Int64) As Boolean
        server.connectionCount() = connectionCount
        Return server.start(port)
    End Function

    Protected Overrides Sub stop_server(ByVal server As rcserve4)
        server.stop()
    End Sub
End Class
